package com.yuyou.tas.terminal.comm;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yuyou.tas.util.tool.HttpClient;

/**
 * 教师端接口
 *
 */
@Service
public class MTAPI {
		
	@Value("${yyfnAddr}")
	public  String yyfnAddr;
	
	/**
	 * openid登陆
	 */
	public  static String login="/api/m/t/wx/login";
	
	/**
	 * 
	 */
	public  static String loginByTercherId="/api/m/t/wx/loginByTeacherId";
	
	/**
	 * 老师详情
	 */
	public  static String teacherDetail="/api/m/t/teacherDetail";
	
	
	public  TeacherDetailVo getTeacherDetail(String accessToken,Long teacherId) throws Exception{
		Map<String, String> params=new HashMap<String, String>();
		params.put("accessToken", accessToken);
		params.put("teacherId", String.valueOf(teacherId));		
		String res =HttpClient.post(yyfnAddr+MTAPI.teacherDetail, params,null);		
		TeacherDetailVo teacherDetailVo=JSONObject.parseObject(res, new TypeReference<TeacherDetailVo>() {});
		return teacherDetailVo;
	}
	
	
	public boolean validaTea(String accessToken,Long teacherId) throws Exception{
		TeacherDetailVo teacherDetailVo=this.getTeacherDetail(accessToken,teacherId);
		TeacherDetailDataVo teacherDetailDataVo=teacherDetailVo.getData();
		TeacherDetailDataTeacherVo teacherDetailDataTeacherVo=teacherDetailDataVo.getTeacher();
		return teacherDetailDataTeacherVo.getTeacherId().longValue()==teacherId.longValue();
	}
	
	
	
}
